import sample

from PyCmpltrtok.common import get_dir_name_ext, sep
from typing import List
import array
import numpy as np

if '__main__' == __name__:
    
    sep('gcd')
    x = 60
    y = 24
    r = sample.gcd(x, y)
    print(f'gcd({x}, {y}) = {r}')
    
    sep('in_mandel')
    pairs = [
        [0, 0],
        [-0.74543, 0.11301],
        [-1.4011, 0.60206],
        [1, 1],
        [2, 2],
    ]
    n = 3
    for p in pairs:
        print(f'n={n}', p, '->', sample.in_mandel(p[0], p[1], n))
        
    sep('divide')
    x = 20
    y = 7
    quotient, remainder = sample.divide(x, y)
    print(f'divide({x}, {y}) -> {quotient}, {remainder}')
    
    sep('avg')
    sep('array.array')
    values = array.array('d', [1, 2, 3, 4, 5])
    print(values, sample.avg(values))
    
    sep('list')
    values = [1, 2, 3, 4, 5]
    print(values, sample.avg(values))
    
    sep('tuple')
    values = (1, 2, 3, 4, 5)
    print(values, sample.avg(values))
    
    sep('np.ndarray')
    values = np.array([1, 2, 3, 4, 5], dtype=float)
    print(values, sample.avg(values))
    
    sep('distance')
    p1 = sample.Point(1, 1)
    p2 = sample.Point(4, 5)
    print(p1.x, p1.y, ';', p2.x, p2.y, '->', sample.distance(p1, p2))
    print(p1.x, p1.y, ';', p2.x, p2.y, '->', sample.distance_my(p1, p2))
    